package com.ss.android.article.share.d;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.text.Html;

import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.browser.R;
import com.ss.android.article.share.e.c;
import com.ss.android.article.share.entity.BaseShareContent;
import com.ss.android.common.lib.MobClickCombiner;

import java.lang.ref.WeakReference;

public final class b extends c {
    private Context a;

    public b(Context arg1) {

        this.a = arg1;
    }

    public final boolean a(BaseShareContent arg7) {
        boolean v0;
        int v5 = Intent.FLAG_ACTIVITY_NEW_TASK;
        int v4 = -2;
        if (arg7 != null && this.a != null) {
            if (((this.a instanceof Activity)) && (((Activity) this.a).isFinishing())) {
                v0 = false;
                return v0;
            }

            Dialog v0_1 = new Dialog(this.a, R.style.ju);
            v0_1.setCancelable(true);
            v0_1.getWindow().setLayout(v4, v4);
            v0_1.getWindow().setGravity(17);
            v0_1.setContentView(com.ss.android.article.browser.R.layout.c3);
            WeakReference v1 = new WeakReference(v0_1);
            v0_1.show();
            Context v3 = this.a;
            Object v0_2 = v1.get();
            if (v0_2 != null && (((Dialog) v0_2).isShowing())) {
                ((Dialog) v0_2).dismiss();
                if (android.support.design.a.isTextEmpty(arg7.getText())) {
                    UIUtils.showImageToast(v3, R.drawable.close_popup_textpage, R.string.a0q);
                    return true;
                }

                MobClickCombiner.onEvent(v3, "xiangping", "system_share_content");
                Intent v0_3 = new Intent("android.intent.action.SEND");
                v0_3.setFlags(v5);
                v0_3.putExtra("android.intent.extra.TEXT", Html.fromHtml(arg7.getText()));
                v0_3.putExtra("android.intent.extra.SUBJECT", arg7.getTitle());
                v0_3.setType("message/rfc822");
                v0_3 = Intent.createChooser(v0_3, v3.getString(com.ss.android.article.browser.R.string.c1));
                v0_3.setFlags(v5);
                try {
                    v3.startActivity(v0_3);
                } catch (Exception v0_4) {
                }
            }
            v0 = true;
        } else {
            v0 = false;
        }

        return v0;
    }
}

